﻿unit CSVEXForm;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Buttons, R4FuncKeys, ToolWin, StdCtrls;

type
  TCSVEXEvent = procedure(Sender:TObject;SN :string) of object;
  TForm3 = class(TForm)
    Label1: TLabel;
    CSVEXPath: TEdit;
    R4Funckeys1: TR4Funckeys;
    R4FuncBtn1: TR4FuncBtn;
    R4FuncBtn2: TR4FuncBtn;
    R4FuncBtn3: TR4FuncBtn;
    R4FuncBtn4: TR4FuncBtn;
    R4FuncBtn5: TR4FuncBtn;
    procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
    procedure R4FuncBtn2Click(Sender: TObject);
    procedure R4FuncBtn4Click(Sender: TObject);
  private
    { Private declarations }
    FOnCSVEXPath : TCSVEXEvent; // 处理结果
  public
    { Public declarations }
    property OnCSVEXPath : TCSVEXEvent read FOnCSVEXPath write FOnCSVEXPath;  //定义 OnCSVEXPath 用于通知父窗体
  end;

var
  Form3: TForm3;

implementation

{$R *.dfm}

procedure TForm3.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  R4Funckeys1.FuncKey(Key);
end;

procedure TForm3.R4FuncBtn2Click(Sender: TObject);
begin
  Close;
end;

procedure TForm3.R4FuncBtn4Click(Sender: TObject);
var
  EXPath : string;
begin
  EXPath := CSVEXPath.Text;
  if Length(EXPath)<=0 then
  begin
    showmessage('The Export Path cannot be empty.');
    exit;
  end;
  if (not DirectoryExists(EXPath)) then
  begin
    showmessage('The Path does not exit,please re-enter.');
    exit;
  end;
  //回传输入的内容给父窗体
  if Assigned(FOnCSVEXPath) then
  begin
    FOnCSVEXPath(Self,EXPath);
  end;

  ModalResult := mrOk;
end;

end.
